#include<iostream>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
int arr[N];
int n;
int main()
{
	cin >> n;
	LL sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		sum += arr[i];
	}
	if (sum % 3) {
		cout << 0 << endl;
		return 0;
	}
	LL av = sum / 3;
	LL ans = 0;
	LL temp = 0;
	LL res = 0;
	for (int i = 0; i < n - 1; i++) {
		temp += arr[i];
		if (temp == 2 * av) {
			ans += res;
		}
		if (temp == av) {
			res++;
		}
	}
	cout << ans << endl;
	return 0;
}